package net.lzzy.lxq.dao;


import net.lzzy.lxq.entities.User;
import org.apache.ibatis.annotations.*;

import java.util.List;


public interface UserInterface {
    @Insert("insert into users(user_name,user_account,user_password,created_at) " +
            "values(#{name},#{account},#{password},#{createdAt})")
    void insertNewUser(String name, String account, String password, long createdAt);

    @Results({
            @Result(property = "name",column = "user_name"),
            @Result(property = "account",column = "user_account"),
            @Result(property = "password",column = "user_password"),
            @Result(property = "createdAt",column = "created_at"),
            @Result(property = "birthday",column = "user_birthday"),
            @Result(property = "hobby",column = "user_hobby"),
            @Result(property = "famous",column = "user_famous"),
            @Result(property = "fans",column = "user_fans"),
            @Result(property = "backgroundImage",column = "user_bg"),
            @Result(property = "avatar",column = "user_avatar"),
            @Result(property = "identity",column = "user_identity"),
            @Result(property = "sex",column = "user_sex"),
            @Result(property = "status",column = "user_status"),
            @Result(property = "thumb",column = "user_thumb"),
    })
    @Select("select * from users where user_account=#{account} and user_password=#{password}")
    User selectUser(@Param("account") String account, @Param("password") String password);

    @Results({
            @Result(property = "name",column = "user_name"),
            @Result(property = "account",column = "user_account"),
            @Result(property = "password",column = "user_password"),
            @Result(property = "createdAt",column = "created_at"),
            @Result(property = "birthday",column = "user_birthday"),
            @Result(property = "hobby",column = "user_hobby"),
            @Result(property = "famous",column = "user_famous"),
            @Result(property = "fans",column = "user_fans"),
            @Result(property = "backgroundImage",column = "user_bg"),
            @Result(property = "avatar",column = "user_avatar"),
            @Result(property = "identity",column = "user_identity"),
            @Result(property = "sex",column = "user_sex"),
            @Result(property = "status",column = "user_status"),
            @Result(property = "thumb",column = "user_thumb"),
    })
    @Select("select * from users")
    List<User> selectAll();
}
